<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ngclass</title>
    <script src="js/angular.js"></script>

    <style>
        .red {
            background-color: red;
        }
    </style>
</head>
<body ng-app="myApp">


<div ng-controller="LotteryController">
    <div ng-class="{red: x > 5}"
         ng-if="x > 5">
        You won!
    </div>
    <button ng-click="x = generateNumber()"
            ng-init="x = 0">
        Draw Number
    </button>
    <p>Number is: {{ x }}</p>
</div>

<script>
    angular.module('myApp',[])
        .controller('LotteryController', function($scope) {
            $scope.generateNumber = function() {
                return Math.floor((Math.random()*10)+1);
            }; });
</script>

</body>
</html>